package zh.javadesign.工厂方法.impl02.store;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import zh.javadesign.工厂方法.Scene.coupon.CouponResult;
import zh.javadesign.工厂方法.Scene.coupon.CouponService;

import java.util.Map;

/**
 * Copyright (C) 广州中和互联网技术有限公司
 *
 * @author 范家微 fanjiawei@borche.cn
 * @date :2021/1/29 11:43
 */
public class CouponCommondityService implements ICommondity {
	private Logger logger = LoggerFactory.getLogger(CouponCommondityService.class);

	@Override
	public void sentCommodity(String uId, String commodityId, String bizId, Map<String, String> extMap) {
		CouponService couponService = new CouponService();
		CouponResult couponResult = couponService.sendCoupon(uId, commodityId, bizId);
		logger.info("请求参数[优惠券] => uId：{} commodityId：{} bizId：{} extMap：{}", uId, commodityId, bizId, JSON.toJSON(extMap));
		logger.info("测试结果[优惠券]：{}", JSON.toJSON(couponResult));
		if (!"0000".equals(couponResult.getCode())) throw new RuntimeException(couponResult.getInfo());
	}
}
